package org.dromara.germbank.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.constant.SystemConstants;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.germbank.domain.BusApplicationContact;
import org.dromara.germbank.domain.BusPartnerClinic;
import org.dromara.germbank.domain.bo.BusApplicationContactBo;
import org.dromara.germbank.domain.bo.BusOperationsAdvertisementBo;
import org.dromara.germbank.domain.bo.BusPartnerClinicBo;
import org.dromara.germbank.domain.vo.BusApplicationContactVo;
import org.dromara.germbank.mapper.BusApplicationContactMapper;
import org.dromara.germbank.service.BusApplicationContactService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 联系我们Service实现类
 *
 * @author congxing
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class BusApplicationContactServiceImpl implements BusApplicationContactService {

    private final BusApplicationContactMapper busApplicationContactMapper;

    /**
     * 查询联系我们管理
     */
    @Override
    public TableDataInfo<BusApplicationContactVo> queryPageList(BusApplicationContactBo bo, PageQuery pageQuery) {

        Page<BusApplicationContactVo> page = busApplicationContactMapper.queryPageList(pageQuery.build(),this.buildQueryWrapper(bo));
        return TableDataInfo.build(page);
    }

    /**
     * 查询联系我们管理
     */
    @Override
    public boolean checkAdNameUnique(BusOperationsAdvertisementBo ad) {
        return false;
    }

    /**
     * 查询联系我们管理
     */
    @Override
    public int insertContact(BusOperationsAdvertisementBo ad) {
        return 0;
    }

    /**
     * 查询联系我们管理
     */
    @Override
    public void updateContactData(BusOperationsAdvertisementBo contact) {

    }

    /**
     * 查询联系我们管理
     */
    @Override
    public void deleteContactCodesDataByIds(List<Long> adCodes) {

    }

    // 分页查询条件
    private Wrapper<BusApplicationContact> buildQueryWrapper(BusApplicationContactBo bo) {
        return Wrappers.<BusApplicationContact>lambdaQuery()



            // 主邮箱（精确）
            .eq(StringUtils.isNotBlank(bo.getEmail()),
                BusApplicationContact::getEmail, bo.getEmail())

            // 电话（精确）
            .eq(StringUtils.isNotBlank(bo.getPhone()),
                BusApplicationContact::getPhone, bo.getPhone())

            // 排序
            .orderByAsc(BusApplicationContact::getId);
    }
}
